<?php
declare (strict_types = 1);

namespace app\mall\model;

use app\mall\enum\MAllStoreStatusEnum;
use app\mall\model\traits\GoodsStockTrait;
use app\mall\model\traits\RegionTrait;
use think\Model;

/**
 * @mixin Model
 */
class MallStore extends MallBase
{
    use RegionTrait;
    use GoodsStockTrait;
    //
    public function getLevelTextAttr()
    {
        return $this->level()->cache()->value('name');
    }

    public function getStatusTextAttr($key, $data)
    {
        return (new MAllStoreStatusEnum($data['status']))->getZhName();
    }

    public function level()
    {
        return $this->belongsTo(MallStoreLevelSetting::class, 'level_flag', 'flag');
    }

    public function storeAccount()
    {
        return $this->hasOne(MallStoreAccount::class, 'id', 'store_id');
    }


}
